'''
''' This sub is called when a record is getting saved. Call MyBase.SaveData()
''' only if duplicate record is not present in the database.
'''
Public Overrides Sub SaveData()
Dim whereStr As String = ${${Table Name}ClassName}.${Primary Key}.UniqueName & " = '" & Me.${Primary Key Control}.Text & "'"
' Check if record already exists before saving.
Dim rec As ${${Table Name}RecordClassName} = ${${Table Name}ClassName}.GetRecord(whereStr)
If (Not IsNothing(rec)) Then
' If record exists, do not save the record
Else
' Save the record if it does not exists
MyBase.SaveData()
End If
End Sub
|